package com.gongpingjialoan.data;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LicenceRecordData implements Serializable
{
    
    /**
	 * 
	 */
    private static final long serialVersionUID = 1502595512199166524L;
    
    /**
	 * 
	 */
    
    private int count;
    
    private int forfeit;
    
    private int fen = 0;
    
    private int unDealt;
    
    private int totalmoney = 0;
    
    private List<Map<String, String>> recordList;
    
    private String plateNumber;
    
    public String getPlateNumber()
    {
        return plateNumber;
    }
    
    public int getCount()
    {
        return count;
    }
    
    public int getForfeit()
    {
        return forfeit;
    }
    
    public int getFen()
    {
        return fen;
    }
    
    public List<Map<String, String>> getRecordList()
    {
        return recordList;
    }
    
    public int getUnDealt()
    {
        return unDealt;
    }
    
    
    public int getTotalmoney()
    {
        return totalmoney;
    }

    public void setTotalmoney(int totalmoney)
    {
        this.totalmoney = totalmoney;
    }

    public LicenceRecordData(String plateNumber, JSONObject json)
    {
        try
        {
            this.plateNumber = "苏" + plateNumber;
            count = json.getInt("count");
            if (count <= 0)
            {
                recordList = new ArrayList<Map<String, String>>();
                return;
            }
            JSONObject data = json.getJSONObject("data");
            forfeit = data.getInt("forfeit");
            JSONArray records = data.getJSONArray("record_list");
            JSONObject record;
            Map<String, String> recordMap;
            recordList = new ArrayList<Map<String, String>>();
            String chuli;
            for (int i = 0; i < records.length(); i++)
            {
                record = records.getJSONObject(i);
                recordMap = new HashMap<String, String>();
                chuli = record.getString("chuli");
                if (chuli.equals("未处理"))
                {
                    unDealt++;
                }
                recordMap.put("chuli", chuli);
                recordMap.put("area", record.getString("area"));
                recordMap.put("fen", record.getInt("fen") + "");
                recordMap.put("money", record.getInt("money") + "");
                recordMap.put("act", record.getString("act"));
                recordMap.put("date", record.getString("date"));


                fen += Integer.parseInt(recordMap.get("fen"));
                totalmoney += Integer.parseInt(recordMap.get("money"));
                recordList.add(recordMap);
            }
            
        }
        catch (JSONException e)
        {
            e.printStackTrace();
        }
    }
    
    
    
}
